
import json
import socket


class SpeakServer(object):

    def __init__(self):
        super(SpeakServer, self).__init__()


    def run_server(self,host,port,buffer):
        sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        sock.bind((host, port))
        sock.listen(100)
        # self.load_debug('启动服务')
        print('servering listening')

        while True:
            try:
                client_sock, client_addr = sock.accept()
                recv = client_sock.recv(buffer)
                # print(chardet.detect(recv))
                # print(recv)
                if recv:
                    data = eval(recv)
                    print(data)
            except Exception as recv_ERR:
                print(str(recv_ERR))

